package WWTPAgent;

import jade.content.ContentElement;
import jade.content.ContentManager;
import jade.core.Agent;
import jade.lang.acl.ACLMessage;
import jade.proto.SimpleAchieveREInitiator;
import wwtp.ontology.RequestHelp;
import wwtp.ontology.Water;

public class RequestForHelpBehaviour extends SimpleAchieveREInitiator
{

	private ContentManager manager;
	private ACLMessage message;
	private Water water;

    public RequestForHelpBehaviour(Agent a,ACLMessage msg) {

        super(a,msg);
        message = msg;
        manager = myAgent.getContentManager();

        //Nos guardamos el agua
        try{
        	ContentElement ce = manager.extractContent(msg);
			water = ((RequestHelp)ce).getWaterToTreat();
		}
		catch (Exception e){
			e.printStackTrace();
		}

        //System.out.println("RequestForHelpBehaviour Creado");
    }

    protected ACLMessage prepareRequest(ACLMessage arg0) {
		// TODO Auto-generated method stub
    	//System.out.println("Prepare Request by " + myAgent.getLocalName());
		return super.prepareRequest(arg0);

	}

    protected void handleInform(ACLMessage inform)
    {
    	myAgent.addBehaviour(new ListenerBehaviour(water));
    }
    	
}